#[doc = "Register `TSENSOR_CTRL` reader"]
pub struct R(crate::R<TSENSOR_CTRL_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<TSENSOR_CTRL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<TSENSOR_CTRL_SPEC>> for R {
    fn from(reader: crate::R<TSENSOR_CTRL_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `TSENSOR_CTRL` writer"]
pub struct W(crate::W<TSENSOR_CTRL_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<TSENSOR_CTRL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<TSENSOR_CTRL_SPEC>> for W {
    fn from(writer: crate::W<TSENSOR_CTRL_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "TSensor power gating polarity.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GATE_TSENSOR_VDDIO_POLAR_A {
    #[doc = "0: The TSensor IP is enabled at 1 and disabled at 0."]
    ONE_ENABLE = 0,
    #[doc = "1: The TSensor IP is enabled at 0 and disabled at 1."]
    ZERO_ENABLE = 1,
}
impl From<GATE_TSENSOR_VDDIO_POLAR_A> for bool {
    #[inline(always)]
    fn from(variant: GATE_TSENSOR_VDDIO_POLAR_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `gate_tsensor_vddio_polar` reader - TSensor power gating polarity."]
pub struct GATE_TSENSOR_VDDIO_POLAR_R(crate::FieldReader<bool, GATE_TSENSOR_VDDIO_POLAR_A>);
impl GATE_TSENSOR_VDDIO_POLAR_R {
    pub(crate) fn new(bits: bool) -> Self {
        GATE_TSENSOR_VDDIO_POLAR_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> GATE_TSENSOR_VDDIO_POLAR_A {
        match self.bits {
            false => GATE_TSENSOR_VDDIO_POLAR_A::ONE_ENABLE,
            true => GATE_TSENSOR_VDDIO_POLAR_A::ZERO_ENABLE,
        }
    }
    #[doc = "Checks if the value of the field is `ONE_ENABLE`"]
    #[inline(always)]
    pub fn is_one_enable(&self) -> bool {
        **self == GATE_TSENSOR_VDDIO_POLAR_A::ONE_ENABLE
    }
    #[doc = "Checks if the value of the field is `ZERO_ENABLE`"]
    #[inline(always)]
    pub fn is_zero_enable(&self) -> bool {
        **self == GATE_TSENSOR_VDDIO_POLAR_A::ZERO_ENABLE
    }
}
impl core::ops::Deref for GATE_TSENSOR_VDDIO_POLAR_R {
    type Target = crate::FieldReader<bool, GATE_TSENSOR_VDDIO_POLAR_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `gate_tsensor_vddio_polar` writer - TSensor power gating polarity."]
pub struct GATE_TSENSOR_VDDIO_POLAR_W<'a> {
    w: &'a mut W,
}
impl<'a> GATE_TSENSOR_VDDIO_POLAR_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: GATE_TSENSOR_VDDIO_POLAR_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The TSensor IP is enabled at 1 and disabled at 0."]
    #[inline(always)]
    pub fn one_enable(self) -> &'a mut W {
        self.variant(GATE_TSENSOR_VDDIO_POLAR_A::ONE_ENABLE)
    }
    #[doc = "The TSensor IP is enabled at 0 and disabled at 1."]
    #[inline(always)]
    pub fn zero_enable(self) -> &'a mut W {
        self.variant(GATE_TSENSOR_VDDIO_POLAR_A::ZERO_ENABLE)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u16) & 0x01) << 3);
        self.w
    }
}
#[doc = "TSensor temperature reporting mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum TSENSOR_MODE_A {
    #[doc = "0: 16-sample averaging single reporting mode."]
    MODE_16_AVG_SINGLE = 0,
    #[doc = "1: 16-sample averaging cyclic reporting mode."]
    MODE_16_AVG_CYCLIC = 1,
    #[doc = "16: Single-sample cyclic reporting mode."]
    MODE_ONE_CYCLIC = 16,
}
impl From<TSENSOR_MODE_A> for u8 {
    #[inline(always)]
    fn from(variant: TSENSOR_MODE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `tsensor_mode` reader - TSensor temperature reporting mode."]
pub struct TSENSOR_MODE_R(crate::FieldReader<u8, TSENSOR_MODE_A>);
impl TSENSOR_MODE_R {
    pub(crate) fn new(bits: u8) -> Self {
        TSENSOR_MODE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> crate::Variant<u8, TSENSOR_MODE_A> {
        use crate::Variant::*;
        match self.bits {
            0 => Val(TSENSOR_MODE_A::MODE_16_AVG_SINGLE),
            1 => Val(TSENSOR_MODE_A::MODE_16_AVG_CYCLIC),
            16 => Val(TSENSOR_MODE_A::MODE_ONE_CYCLIC),
            i => Res(i),
        }
    }
    #[doc = "Checks if the value of the field is `MODE_16_AVG_SINGLE`"]
    #[inline(always)]
    pub fn is_mode_16_avg_single(&self) -> bool {
        **self == TSENSOR_MODE_A::MODE_16_AVG_SINGLE
    }
    #[doc = "Checks if the value of the field is `MODE_16_AVG_CYCLIC`"]
    #[inline(always)]
    pub fn is_mode_16_avg_cyclic(&self) -> bool {
        **self == TSENSOR_MODE_A::MODE_16_AVG_CYCLIC
    }
    #[doc = "Checks if the value of the field is `MODE_ONE_CYCLIC`"]
    #[inline(always)]
    pub fn is_mode_one_cyclic(&self) -> bool {
        **self == TSENSOR_MODE_A::MODE_ONE_CYCLIC
    }
}
impl core::ops::Deref for TSENSOR_MODE_R {
    type Target = crate::FieldReader<u8, TSENSOR_MODE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `tsensor_mode` writer - TSensor temperature reporting mode."]
pub struct TSENSOR_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> TSENSOR_MODE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TSENSOR_MODE_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "16-sample averaging single reporting mode."]
    #[inline(always)]
    pub fn mode_16_avg_single(self) -> &'a mut W {
        self.variant(TSENSOR_MODE_A::MODE_16_AVG_SINGLE)
    }
    #[doc = "16-sample averaging cyclic reporting mode."]
    #[inline(always)]
    pub fn mode_16_avg_cyclic(self) -> &'a mut W {
        self.variant(TSENSOR_MODE_A::MODE_16_AVG_CYCLIC)
    }
    #[doc = "Single-sample cyclic reporting mode."]
    #[inline(always)]
    pub fn mode_one_cyclic(self) -> &'a mut W {
        self.variant(TSENSOR_MODE_A::MODE_ONE_CYCLIC)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 1)) | (((value as u16) & 0x03) << 1);
        self.w
    }
}
#[doc = "TSENSOR_CTRL switch.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TSENSOR_ENABLE_A {
    #[doc = "0: disabled."]
    DISABLED = 0,
    #[doc = "1: enabled."]
    ENABLED = 1,
}
impl From<TSENSOR_ENABLE_A> for bool {
    #[inline(always)]
    fn from(variant: TSENSOR_ENABLE_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `tsensor_enable` reader - TSENSOR_CTRL switch."]
pub struct TSENSOR_ENABLE_R(crate::FieldReader<bool, TSENSOR_ENABLE_A>);
impl TSENSOR_ENABLE_R {
    pub(crate) fn new(bits: bool) -> Self {
        TSENSOR_ENABLE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TSENSOR_ENABLE_A {
        match self.bits {
            false => TSENSOR_ENABLE_A::DISABLED,
            true => TSENSOR_ENABLE_A::ENABLED,
        }
    }
    #[doc = "Checks if the value of the field is `DISABLED`"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        **self == TSENSOR_ENABLE_A::DISABLED
    }
    #[doc = "Checks if the value of the field is `ENABLED`"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        **self == TSENSOR_ENABLE_A::ENABLED
    }
}
impl core::ops::Deref for TSENSOR_ENABLE_R {
    type Target = crate::FieldReader<bool, TSENSOR_ENABLE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `tsensor_enable` writer - TSENSOR_CTRL switch."]
pub struct TSENSOR_ENABLE_W<'a> {
    w: &'a mut W,
}
impl<'a> TSENSOR_ENABLE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TSENSOR_ENABLE_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "disabled."]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut W {
        self.variant(TSENSOR_ENABLE_A::DISABLED)
    }
    #[doc = "enabled."]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut W {
        self.variant(TSENSOR_ENABLE_A::ENABLED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x01) | ((value as u16) & 0x01);
        self.w
    }
}
impl R {
    #[doc = "Bit 3 - TSensor power gating polarity."]
    #[inline(always)]
    pub fn gate_tsensor_vddio_polar(&self) -> GATE_TSENSOR_VDDIO_POLAR_R {
        GATE_TSENSOR_VDDIO_POLAR_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bits 1:2 - TSensor temperature reporting mode."]
    #[inline(always)]
    pub fn tsensor_mode(&self) -> TSENSOR_MODE_R {
        TSENSOR_MODE_R::new(((self.bits >> 1) & 0x03) as u8)
    }
    #[doc = "Bit 0 - TSENSOR_CTRL switch."]
    #[inline(always)]
    pub fn tsensor_enable(&self) -> TSENSOR_ENABLE_R {
        TSENSOR_ENABLE_R::new((self.bits & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bit 3 - TSensor power gating polarity."]
    #[inline(always)]
    pub fn gate_tsensor_vddio_polar(&mut self) -> GATE_TSENSOR_VDDIO_POLAR_W {
        GATE_TSENSOR_VDDIO_POLAR_W { w: self }
    }
    #[doc = "Bits 1:2 - TSensor temperature reporting mode."]
    #[inline(always)]
    pub fn tsensor_mode(&mut self) -> TSENSOR_MODE_W {
        TSENSOR_MODE_W { w: self }
    }
    #[doc = "Bit 0 - TSENSOR_CTRL switch."]
    #[inline(always)]
    pub fn tsensor_enable(&mut self) -> TSENSOR_ENABLE_W {
        TSENSOR_ENABLE_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "TSENSOR_CTRL is the TSensor control register.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tsensor_ctrl](index.html) module"]
pub struct TSENSOR_CTRL_SPEC;
impl crate::RegisterSpec for TSENSOR_CTRL_SPEC {
    type Ux = u16;
}
#[doc = "`read()` method returns [tsensor_ctrl::R](R) reader structure"]
impl crate::Readable for TSENSOR_CTRL_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [tsensor_ctrl::W](W) writer structure"]
impl crate::Writable for TSENSOR_CTRL_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets TSENSOR_CTRL to value 0"]
impl crate::Resettable for TSENSOR_CTRL_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
